/**
 * @Author 12629
 * @Description：
 */
class Student {
    /*
    字段/属性/成员变量：
    1. 定义在类的内部 方法的外部
    2. 这些成员变量 可以不初始化，默认值的。 引用类型-》null  boolean->false 其他的是对应的0值
     */
    private String name = "gaobo";//实例成员变量
    private int age;
    private String sex;
    public static String classRoom = "112Java";

    static {
        System.out.println("静态代码块.....");
        //this.name = "zhangsan";
        classRoom = "112JavaCool";
    }

    static {

    }

    {
        System.out.println("构造块/实例代码块/非静态代码块....");
        this.name = "zhangsan";
    }

    {

    }

    //不带参数的构造方法的问题是：当没有提供任何构造方法的时候，会默认有。但是一旦写了任何一种构造方法，他都不会在存在了！
    public Student() {
        //this(,,);
        System.out.println("不带参数的构造方法！");
    }

    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        System.out.println("带有3个参数的构造方法！");
    }




    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    /*
       成员方法
    */

    public void sleep() {
        //getClassRoom();可以的
        System.out.println(this.name+" 正在睡觉！");
    }

    public void show() {
        System.out.println("姓名："+this.name
                +" 年龄："+this.age+" 性别："+this.sex);
    }

    public void eat() {
        System.out.println(this.name+" 正在吃饭！");
    }
    public static String getClassRoom() {
        Student student = new Student();
        student.eat();
        return classRoom;
    }


    @Override
    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", 年龄=" + age +
                ", 性别='" + sex + '\'' +
                '}';
        //return "gaobo";
    }
}

//类的 使用者
public class Test2 {


    public static void main(String[] args) {
        Student student1 = new Student("张三",10,"男");
        System.out.println(student1);

        //student1.show();

    }





    public static void main4(String[] args) {
        Student student = new Student();
        //System.out.println(student.getName());
        System.out.println("=======");
        Student student2 = new Student();
    }


    public static void main3(String[] args) {
        int i = 10;
        //if(i == 10)
        {
            //定义在方法里面的 普通代码块
            int a = 10;
            System.out.println(a);
        }

        //System.out.println(a);
    }

    public  void fib() {

    }

    public static void main2(String[] args) {
        Test2 test2 = new Test2();
        test2.fib();

        /*Student student1 = new Student("张三",10,"男");
        Student student2 = new Student("李四",8,"男");
        Student student3 = new Student("王五",15,"男");

        System.out.println(student1.classRoom);*/

        //System.out.println(Student.classRoom);

      /*  Student student1 = null;
        System.out.println(student1.classRoom);

        System.out.println(student1.getName());*/

        String ret = Student.getClassRoom();
        System.out.println(ret);


    }
    public static void main1(String[] args) {
        Student student1 = new Student();
        //student1.name = "wangwu"; 不能直接访问


        //
        student1.setName("wangwu");
        System.out.println(student1.getName());


        student1.eat();

        //name
    }
}